package com.sa.web.util.interceptoer;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.StrutsStatics;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.sa.web.bean.AdminBean;

public class ManagerInterceptor extends AbstractInterceptor {

	@Override
	public String intercept(ActionInvocation ai) throws Exception {
		
		HttpServletRequest request= (HttpServletRequest)  ai.getInvocationContext().get(StrutsStatics.HTTP_REQUEST);
		String url =  request.getServletPath();
		if(!url.endsWith("adminLogin.html") && !url.endsWith("indexB.html")){
			Map<String , Object> session = ai.getInvocationContext().getSession();
			AdminBean admin = (AdminBean) session.get("Manager");
			if(admin == null){
				return "managernologin";
			}
		}
		return ai.invoke();
	}
	
	

}
